import React, { useEffect, useState } from 'react'
import { NavBar } from 'antd-mobile'
import '../style/add_address.css'

import Add_data from './add_data'


export default React.memo(function Add_address() {

    useEffect(() => {
        const integralShop = sessionStorage.getItem('integralShop')
        if (integralShop) {
            if ((JSON.parse(integralShop).flag) === true) {
                sessionStorage.setItem('integralShop', JSON.stringify({ flag: false }))
                window.location.reload()
            }
        } else {
            sessionStorage.setItem('integralShop', JSON.stringify({ flag: true }))
        }
    }, [])


    const back = () => {
        window.history.back()
        sessionStorage.setItem('integralShop', JSON.stringify({ flag: true }))
    }

    return (
        <div className='add-address'>
            <div className='add-header'>
                <NavBar onBack={back}>
                    新增地址
                </NavBar>
            </div>

            <div className='add-content'>
                <Add_data />
            </div>
        </div>
    )
})
